<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:include="fragments/easyui_insdep_head :: easyui_insdep_head" th:with="title='添加员工'">
</head>

<script type="text/javascript" src="http://www.gongjuji.net/Content/files/jquery.md5.js"></script>

<body>
<div style="width: 400px; padding: 60px 90px;">
    <form id="ff" name="ff" method="post" action="/staff/">
        <div style="margin-bottom: 20px">
            <input class="easyui-textbox theme-textbox-radius" id="fname" name="staffName" style="width: 100%"
                   data-options="required:true, label:'职工姓名:'"/>
        </div>

        <div style="margin-bottom: 20px">
            <input class="easyui-passwordbox easyui-validatebox theme-textbox-radius" id="ipassword1"
                    iconWidth="28" style="width: 100%"
                   data-options="required:true,label:'职工密码:'" validType="equalTo['#ipassword2']" invalidMessage="两次输入密码不匹配"/>
        </div>

        <input type="hidden" name="staffPwdSalt" id="staffPwdSalt" />
        <input type="hidden" name="staffPwd" id="staffPwd" />

        <div style="margin-bottom: 20px">
            <input class="easyui-passwordbox easyui-validatebox theme-textbox-radius" id="ipassword2"
                   style="width: 100%" iconWidth="28" data-options="required:true,label:'重复密码:'"
                   validType="equalTo['#ipassword1']" invalidMessage="两次输入密码不匹配"/>
        </div>

        <div style="text-align:center;padding:5px">
            <a href="javascript:void(0)" class="easyui-linkbutton" style="width: 100%" onclick="submitForm()">提交</a>
        </div>
    </form>
</div>
<script type="text/javascript">
    //<![CDATA[
    $(function () {
        $('#ff').form({
            success: function (data) {     // 提交成功后的回调函数。
                data = data == "success" ? "添加成功" : "添加失败";
                $.messager.alert('结果', data, 'info');
            }
        });
    });

    function submitForm() {
        $("#staffPwdSalt").val($.md5("" + parseInt(Math.random() * 100000)));
        $("#staffPwd").val($("#ipassword1").val());
        $("#ff").submit();
    }

    $.extend($.fn.validatebox.defaults.rules, {
        /*必须和某个字段相等*/
        equalTo: { validator: function (value, param) { return $(param[0]).val() == value; }, message: '字段不匹配' }
    });
    //]]>
</script>

</body>
</html>